from django.db import models

from app.utils import PROVINCE_CHOICES, CITY_CHOICES, AREA_CHOICES
from .fm_user import FMUser


class MailingAddress(models.Model):
    user = models.ForeignKey(FMUser, verbose_name=u'用户')
    province = models.IntegerField(choices=PROVINCE_CHOICES, verbose_name=u'省', default=32)
    city = models.IntegerField(choices=CITY_CHOICES, verbose_name=u'市/镇', default=3201)
    area = models.IntegerField(choices=AREA_CHOICES, verbose_name=u'区/乡', default=320101)
    address = models.TextField(verbose_name=u'住址')
    addressee = models.CharField(max_length=30, verbose_name=u'收件人')
    phone = models.CharField(max_length=11, verbose_name=u'手机号')
    is_default = models.BooleanField(verbose_name=u'默认地址', default=False)

    def __str__(self):
        return self.get_province_display() + self.get_city_display() + self.get_area_display() + self.address

    class Meta:
        verbose_name = u'邮寄地址'
        verbose_name_plural = u'邮寄地址'
